import React,{ Component } from 'react';
// import constans from '../constan';
import { List, InputItem, WingBlank, Button, WhiteSpace } from 'antd-mobile';
import { connect } from 'dva';
class LoginPage extends Component {
    constructor (props) {
        super(props);
        this.state = {
            id:'',
            pwd:''
        }
    }
    componentDidMount() {
    }

    login(){
        const {id, pwd} = this.state;
        this.props.dispatch({ type:'user/login' , payload:{id, pwd} })
    }
    render() {
    // const {user} = this.props;
    return (
        <div> 
        <WingBlank size = 'lg'>
        <WhiteSpace md = 'xl' />
        <List>
          <InputItem
            placeholder="您的账号"
            value={ this.state.id }
            onChange={(value) => this.setState({id: value})}
          >账号</InputItem>
          <InputItem
            type="password"
            placeholder="****"
            value={this.state.pwd}
            onChange={(value) => this.setState({ pwd: value })}
          >密码</InputItem>
          </List>
          <WhiteSpace md = 'xl' />
          <Button 
            type="primary"
            onClick = {(e) => {
                this.login()
            }}
          >登陆</Button>
          </WingBlank>
        </div>
    )
    }
}

function mapStateToProps({user}) {
    return {
        user
    }
}

export default connect(mapStateToProps)(LoginPage);